def flatten(l: List[Any]): List[Any] = l flatMap {
    case ms: List[_] => flatten(ms)
    case e => List(e)
  }
  
  
 //program implements flatMap function. Can be used to find largest/smallest node, etc.